package com.hospital.dictionary.module.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hospital.common.core.result.SuccessTip;
import com.hospital.common.core.result.Tip;
import com.hospital.common.core.utils.StringUtil;
import com.hospital.dictionary.module.controller.base.BaseController;
import com.hospital.dictionary.module.controller.vo.QueryListVo;
import com.hospital.dictionary.module.entity.ClinicItemDict;
import com.hospital.dictionary.module.service.ClinicItemDictService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lvyao
 * @since 2022-02-14
 */
@RestController
@RequestMapping("/module/clinicItemDict")
public class ClinicItemDictController extends BaseController<ClinicItemDict, ClinicItemDictService> {

    @Resource
    private ClinicItemDictService clinicItemDictService;

    @PostMapping(value = "/queryClinicItem", produces = {"application/json;charset=UTF-8;"})
    public Tip getPatinfo(@RequestBody(required = false) QueryListVo queryListVo, HttpServletRequest request) {
        String fieldName = queryListVo.getFieldName();
        String fieldVal = queryListVo.getFieldVal();
        List<ClinicItemDict> list = clinicItemDictService.list(new QueryWrapper<ClinicItemDict>().like(StringUtil.camelToUnderline(fieldName), fieldVal));
        return new SuccessTip(list) ;
    }
}

